//
//  collectionView.m
//  iNews
//
//  Created by lanou3g on 14-12-12.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "collectionView.h"

#import "articleTableViewController.h"
#import "prictureTableViewController.h"
@implementation collectionView

-(void)dealloc{

    [_collTab release];
    [_collectionSegment release];
    [_collectionScrollV release];
    [super dealloc];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        [self addviews];
    }
    return self;
}

-(void)addviews{

    
    
    //创建segment
    NSArray *arr=@[@"文章",@"图片"];
    self.collectionSegment=[[[UISegmentedControl alloc]initWithItems:arr] autorelease];
    self.collectionSegment.selectedSegmentIndex=0;
    //self.collectionSegment.tintColor=[UIColor redColor];
    //self.segment.backgroundColor=[UIColor grayColor];//改变未选中视图颜色(背景颜色)
    self.collectionSegment.frame=CGRectMake(100,64,120,20);
    
    //self.collectionSegment.layer.borderColor = [UIColor whiteColor].CGColor;
    [self addSubview:self.collectionSegment];
    
    
    //创建一个ScrollView
    self.collectionScrollV=[[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.collectionSegment.frame), [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - CGRectGetHeight(self.collectionSegment.frame) - 108)] autorelease];
   // self.collectionScrollV.backgroundColor=[UIColor orangeColor];
    //设置显示内容页数
    self.collectionScrollV.contentSize=CGSizeMake([UIScreen mainScreen].bounds.size.width*2, [UIScreen mainScreen].bounds.size.height - CGRectGetHeight(self.collectionSegment.frame) - 108) ;
    //设置滑动为分页滑动
    self.collectionScrollV.pagingEnabled=YES;
    self.collectionScrollV.bounces=NO;//撞到边框是否有反弹
    [self addSubview:self.collectionScrollV];
    
    
    
    //
    self.arcticle = [[[articleTableViewController alloc] init] autorelease];
    self.arcticle.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.collectionScrollV.frame), CGRectGetHeight(self.collectionScrollV.frame)) style:UITableViewStyleGrouped];
    self.arcticle.tableView.tag = 101;
    //self.arcticle.tableView.backgroundColor = [UIColor yellowColor];
    [self.collectionScrollV addSubview:self.arcticle.tableView];
    
    
    self.picture = [[[prictureTableViewController alloc] init] autorelease];
    self.picture.tableView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width*1, 0, CGRectGetWidth(self.collectionScrollV.frame), CGRectGetHeight(self.collectionScrollV.frame));
    
    self.picture.tableView.tag = 102;
    [self.collectionScrollV addSubview:self.picture.tableView];
    
    

    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
